package org.smart4j.aopdemo.aspectj;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class GreetingAspect {

    @Around("execution(* org.smart4j.aopdemo.simple.GreetingImpl.*(..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        before();
        Object result = pjp.proceed();
        after();
        return result;
    }

    @Around("@annotation(org.smart4j.aopdemo.aspectj.Tag)")
    public Object aroundTag(ProceedingJoinPoint pjp) throws Throwable {
        before();
        Object result = pjp.proceed();
        after();
        return result;
    }


    private void after() {
        System.out.println(" after");
    }

    private void before() {
        System.out.println(" before");
    }


}
